/**
 * @file Define all constants used in this project
 * 
 * @author Steve Gao<gaofu@parllay.com>
 */


/**
 * The constants for all system services
 */
const SystemServices = {
    LOG_SERVICE: 'log-service',
    USER_SERVICE: 'user-service',
    WALL_SERVICE: 'wall-service',
    WECHAT_SERVICE: 'wechat-service',
    WEIBO_SERVICE: 'weibo-service',
    WECHAT_MESSAGE_SERVICE: 'wechat-message-service',
    SALES_SERVICE: 'sales-service',
    QINIU_SERVICE: 'qiniu-service',
    OPS_SERVICE: 'ops-service',
    DIANPING_SERVICE: 'dianping-service',
    MAIL_SERVICE: 'mail-service',
    BLUEMP_SERVICE: 'bluemp-service',
    I18N_SERVICE: 'i18n-service',
    CRAWLER_SERVICE: 'crawler-service',
    PARTNER_SERVICE: 'partner-service'
};

exports.SystemServices = SystemServices

const Configuration = {
    SERVER: 'server',
    APPLICATION: 'application',
    WEB_CONTROLLER: 'web_controller',
    SESSION: 'session',
    WECHAT: 'wechat',
    WEIBO: "weibo",
    REDIS: 'redis',
    MYSQL: 'mysql',
    MONGOOSE: 'mongoose',
    QINIU: 'qiniu',
    ALIPAY: 'alipay',
    SEND_CLOUD: 'send_cloud',
    LOG: 'logging',
    TV_METADATA: 'tv_app_metadata_file',
    OPS: 'ops',
    MAIL: 'mail',
    BLUEMP: 'bluemp',
    MAILCHIMP: 'mailchimp'
};

/**
 * The constants for all configurations 
 */
exports.Configuration = Configuration;

/**
 * The constants for HTTP verbs and onwall non-standard verbs
 */
const HTTP_VERBS = {
    POST: 'post',
    GET: 'get',
    PUT: 'put',
    DELETE: 'delete',
    ALL: 'all', // Not standard verb in http/1.1 protocol
    ERROR: 'error' // Not a standard verb in http/1.1 protocol
};

exports.HTTP_VERBS = HTTP_VERBS;

/**
 * The constants for HTTP status code
 */
const HTTP_STATUSES = {
    NOT_FOUND           : 404,
    INTERNAL_ERROR      : 500,
    SERVER_UNAVAILABLE  : 503
};

exports.HTTP_STATUSES = HTTP_STATUSES;

/**
 * WeChat Message Type
 */
const WeChatMessageTypes = {
    TEXT: 'text',
    IMAGE: 'image',
    VOICE: 'voice',
    VIDEO: 'video',
    SHORT_VIDEO: 'shortvideo',
    LOCATION: 'location',
    LINK: 'link',
    EVENT: 'event'
};

exports.WeChatMessageTypes = WeChatMessageTypes;

/**
 * WeChat Event Type
 */
const WeChatEventTypes = {
    SUBSCRIBE: 'subscribe',
    UNSUBSCRIBE: 'unsubscribe',
    SCAN: 'SCAN',
    LOCATION: 'LOCATION',
    CLICK: 'CLICK',
    VIEW: 'VIEW'
};

exports.WeChatEventTypes = WeChatEventTypes;

/**
 * WeChat customer service message types
 */
const WeChatCSMessageTypes = {
    TEXT: 'text',
    IMAGE: 'image',
    VOICE: 'voice',
    VIDEO: 'video',
    MUSIC: 'music',
    NEWS: 'news',
    MP_NEWS: 'mpnews',
    WX_CARD: 'wxcard'
};

exports.WeChatCSMessageTypes = WeChatCSMessageTypes;

/**
 * WeChat test constants
 */
const WeChatTestConstants = {
    TESTCOMPONENT_MSG_TYPE_TEXT: "TESTCOMPONENT_MSG_TYPE_TEXT",
    TESTCOMPONENT_MSG_TYPE_TEXT_CALLBACK: "TESTCOMPONENT_MSG_TYPE_TEXT_callback",
    QUERY_AUTH_CODE: "QUERY_AUTH_CODE:",
    FROM_CALLBACK: "from_callback",
    FROM_API: "_from_api"
};

exports.WeChatTestConstants = WeChatTestConstants;

/**
 * The default message for replying to WeChat
 */
const DefaultWeChatReplyMessages = {
    SUCCESS: 'success',
    EMPTY: ''
};

exports.DefaultWeChatReplyMessages = DefaultWeChatReplyMessages;

const CriticalErrors = {
    EADDRINUSE              : "EADDRINUSE",
    NOT_FOUND_CONFIG_FILE   : "NOT_FOUND_CONFIG_FILE",
    WEB_REQUEST_ERROR       : "WEB_REQUEST_ERROR"
};

exports.CriticalErrors = CriticalErrors;

/**
 * The application supported events
 */
const ApplicationEvents = {
    "TERMINATING"           : "terminating",
    "MAINTAINING"           : "maintaining",
    "RESUME"                : "resume",
    "HANGUP"                : "hangup",
    "UNCAUGHT_EXCEPTION"    : "exception",
    "SERVICE_ERROR"         : "service_error",
    "WEB_REQUEST_ERROR"     : "web_request_error"
};

exports.ApplicationEvents = ApplicationEvents;


const EmailTemplates = {
    TRIAL_WELCOME : 'supports/marketing/templates/trial-welcome.html',
    SERVICE_ERROR: 'supports/ops/templates/service_error.html',
    WEB_REQUEST_ERROR: 'supports/ops/templates/web_request_error.html'
};

exports.EmailTemplates = EmailTemplates;